/*
 * StreamFormat.h
 *
 *  Created on: Mar 27, 2013
 *      Author: root
 */

#ifndef STREAMFORMAT_H_
#define STREAMFORMAT_H_

#include "av_format.h"

/*codec id*/
enum CodecID{CODEC_ID_NONE,CODEC_ID_H264,CODEC_ID_AAC};

/*
*media info
*/
struct mediaInfo
{
	uint32_t width;
	uint32_t height;
	uint32_t framerate;
	uint32_t video_bts;
	uint16_t video_codec_id;
	uint32_t audio_sample_rate;
	uint32_t audio_sample_size;
	uint32_t audio_channel;
	uint32_t audio_bts;
	uint16_t audio_codec_id;
	uint8_t  *priva_data;
	uint16_t priva_data_len;
	uint8_t  audio_config[64];
	uint16_t audio_config_len;
	size_t   media_header_len;
};

/**
 *AVCDecoderConfiguration
 */
struct AVCDecoderConfiguration
{
	uint8_t configurationVersion;
	uint8_t AVCProfileIndication;
	uint8_t profile_compatibility;
	uint8_t AVCLevelIndication;
	uint8_t lengthSizeMinusOne;/*bit(6) reserved = ‘111111’b;*/
	uint8_t numOfSequenceParameterSets;/*bit(3) reserved = ‘111’b;*/
	/*for (i=0; i< numOfSequenceParameterSets; i++) {
		unsigned int(16) sequenceParameterSetLength ;
		bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;
	}*/
	uint8_t numOfPictureParameterSets;
	/*for (i=0; i< numOfPictureParameterSets; i++) {
		unsigned int(16) pictureParameterSetLength;
		bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;
	}*/
	uint16_t sps_size;
	uint8_t  *sps_buf;
	uint8_t  pps_num;
	uint16_t pps_size;
	uint8_t  *pps_buf;
	AVCDecoderConfiguration()
	{
		configurationVersion = 0;
		AVCProfileIndication = 0;
		profile_compatibility = 0;
		AVCLevelIndication = 0;
		lengthSizeMinusOne = 0xff;
		numOfSequenceParameterSets = 0xe1;
		sps_size = 0;
		sps_buf = NULL;
		pps_num = 1;
		pps_size = 0;
		pps_buf = NULL;
	}
};

/*
*aac audio config
*/
struct AACDecoderConfiguration
{
	uint32_t audio_sample_rate;
	uint32_t audio_sample_size;
	uint32_t audio_channel;
	/*FLV  AAC AudioSpecificConfig*/
	uint16_t ObjectProfile;/*(AAC main ~1, AAC lc ~2, AAC ssr ~3), 通常选中1；*/
	uint16_t SamplingFrequencyIndex;/*(0 ~ 96000， 1~88200， 2~64000， 3~48000， 4~44100， 5~32000， 6~24000， 7~ 22050， 8~16000...)*/
	uint16_t ChannelConfiguration;/*单声道对应1，双声道对应2*/
	uint16_t TFSpecificConfig;/*标准14496-3中（1.2 T/F Audio Specific Configuration）的讲解，这里恒定的设置为1.*/
	AACDecoderConfiguration()
	{
		audio_sample_rate = 48000;
		audio_sample_size = 16;
		audio_channel = 2;

		ObjectProfile = 1;
		SamplingFrequencyIndex = 3;
		ChannelConfiguration = 2;
		TFSpecificConfig = 1;
	}
};

/*
*aac audio samplie list
*/
const int AAC_SAMPLE_RATE[16] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,16000, 12000, 11025, 8000, 7350, 0, 0 ,0};


#endif /* STREAMFORMAT_H_ */
